// Drummer Server
// by Andrea Bianchi
// drummer.alsoplantsfly.com


// Made with PROCESSING 1.0.3 on Intel Mac, Mac OS X 10.5.6


/*
Copyright (C) 2009, Andrea Bianchi

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/


// CONSTANTS
import java.io.*;
import java.net.*;
import java.util.*;


static final int INSTRUMENTS= 12;
static final int WIDTH= 320;
static final int HEIGHT= 192;


// GLOBALS - Main program Objects
PImage backgroundImg;
DrummerNetwork netw;
DrummerPlayer player;
ButtonArray buttons;
String kit="kit1";



// *** PROGRAM ENTRY POINT  ***
void setup(){
  size(WIDTH, HEIGHT);
  smooth();


  backgroundImg= loadImage("bg.jpg"); 
  player= new DrummerPlayer();
  netw= new DrummerNetwork (this);
  buttons= new ButtonArray();
}



void draw(){
  if (netw.isInitialized())
  {
    netw.update();
  }
  
  
  image(backgroundImg,0,0);
  buttons.draw();
}


void mousePressed()
{
  buttons.press();
}


// it will be called when network get a message
void playSound (String ip, String instrument)
{
  try{
  player.play (Integer.parseInt(instrument), kit);  
  }catch (Exception e){}
}


void setKit1(boolean v)
{
  if (v)
    kit="kit1";
  else
    kit="kit2";
}


